﻿<Window x:Class="ASPItalia.ModelVirtualCasting.WPF.Views.MainView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:vm="http://schemas.aspitalia.com/ModelVirtualCasting/XAML/ViewModels"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:dd="clr-namespace:ASPItalia.ModelVirtualCasting.WPF.DragDrop"
        mc:Ignorable="d"
        d:DataContext="{d:DesignData Source=/SampleData/MainViewModelSample.xaml}"
        Height="500"
        Width="600"
        Title="{Binding Path=Title}">
    <Window.TaskbarItemInfo>
        <TaskbarItemInfo>
        </TaskbarItemInfo>
    </Window.TaskbarItemInfo>

    <Window.Resources>
        <dd:ItemsControlDragSourceAdvisor x:Key="itemsControlDragSourceAdvisor"
                                          RemoveOnDrop="False" />
        <dd:ItemsControlDragTargetAdvisor x:Key="itemsControlDragTargetAdvisor" />

        <dd:ModelDragTargetAdvisor x:Key="modelDragTargetAdvisor" />
        <dd:ModelDragSourceAdvisor x:Key="modelDragSourceAdvisor" />

        <Style x:Key="CandidateItemStyle"
               BasedOn="{StaticResource CandidateItemContainerStyle}"
               TargetType="{x:Type ListBoxItem}">
            <Setter Property="dd:DragDropManager.DragSourceAdvisor"
                    Value="{StaticResource itemsControlDragSourceAdvisor}" />
        </Style>

        <Style x:Key="ModelItemStyle"
               BasedOn="{StaticResource CandidateItemContainerStyle}"
               TargetType="{x:Type ListBoxItem}">
            <Setter Property="dd:DragDropManager.DropTargetAdvisor"
                    Value="{StaticResource itemsControlDragTargetAdvisor}" />
        </Style>
        <Style x:Key="ModelDetailsgridStyle"
               TargetType="{x:Type FrameworkElement}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding CurrentModel}"
                             Value="{x:Null}">
                    <Setter Property="Visibility"
                            Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Window.Background>
        <RadialGradientBrush>
            <GradientStop Color="Black"
                          Offset="0" />
            <GradientStop Color="#FF272727"
                          Offset="1" />
        </RadialGradientBrush>
    </Window.Background>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.15*" />
            <RowDefinition Height="0.7*" />
            <RowDefinition Height="0.15*" />
        </Grid.RowDefinitions>

        <Border DataContext="{Binding CurrentModel}"
                Grid.RowSpan="3">
            <Image Source="{Binding Multimedia/ImageSource}"
                   Stretch="UniformToFill">
                <Image.Effect>
                    <BlurEffect Radius="9"
                                RenderingBias="Quality" />
                </Image.Effect>
            </Image>
        </Border>
        <DockPanel d:LayoutOverrides="Height">

            <TextBox TextWrapping="Wrap"
                     Text="{Binding ModelSearch, UpdateSourceTrigger=PropertyChanged}"
                     Style="{DynamicResource SimpleTextBox}"
                     Width="150"
                     Height="30" />

            <ListBox dd:DragDropManager.DropTargetAdvisor="{StaticResource itemsControlDragTargetAdvisor}"
                     Style="{StaticResource SelectedCandidateListBoxStyle}"
                     ItemsSource="{Binding Models}"
                     ItemContainerStyle="{StaticResource ModelItemStyle}"
                     IsSynchronizedWithCurrentItem="True" />

        </DockPanel>

        <Image Source="/ASPItalia.ModelVirtualCasting.WPF;Component/Style/Logo.png"
               Stretch="None"
               HorizontalAlignment="Center"
               VerticalAlignment="Center"
               Grid.RowSpan="3" />
        <DockPanel ScrollViewer.HorizontalScrollBarVisibility="Auto"
                   Grid.Row="2">

            <TextBox Style="{DynamicResource SimpleTextBox}"
                     Text="{Binding CandidateSearch, UpdateSourceTrigger=PropertyChanged}"
                     Width="150"
                     Height="30"
                     VerticalAlignment="Center"
                     HorizontalAlignment="Center" />

            <ListBox ItemsSource="{Binding Candidates}"
                     IsSynchronizedWithCurrentItem="True"
                     ItemContainerStyle="{StaticResource CandidateItemStyle}"
                     Style="{DynamicResource CandidateListBoxStyle}" />

        </DockPanel>
        <Border Grid.Row="1"
                dd:DragDropManager.DropTargetAdvisor="{StaticResource modelDragTargetAdvisor}">
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1"
                                     StartPoint="0.5,0">
                    <GradientStop Color="#7F000000"
                                  Offset="0" />
                    <GradientStop Color="#7F000000"
                                  Offset="1" />
                    <GradientStop Color="#00000000"
                                  Offset="0.06" />
                    <GradientStop Color="#02000000"
                                  Offset="0.94" />
                </LinearGradientBrush>
            </Border.Background>
            <Grid Margin="60"
                  Style="{StaticResource ModelDetailsgridStyle}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="0.738*" />
                    <RowDefinition Height="0.262*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.062*" />
                    <ColumnDefinition Width="0.208*" />
                    <ColumnDefinition Width="0.73*" />
                </Grid.ColumnDefinitions>

                <Border BorderThickness="1"
                        Background="#9BFFFFFF"
                        CornerRadius="5"
                        Grid.ColumnSpan="3"
                        Visibility="Visible"
                        Grid.RowSpan="2" />
                <Border Background="Black"
                        RenderTransformOrigin="0.5,0.5"
                        Margin="-23.333,-4.667,6.165,4.667"
                        Grid.RowSpan="2">
                    <Border.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform ScaleX="0.8"
                                            ScaleY="0.8" />
                            <SkewTransform />
                            <RotateTransform Angle="-3.34" />
                            <TranslateTransform />
                        </TransformGroup>
                    </Border.RenderTransform>
                    <TextBlock RenderTransformOrigin="0.5,0.5"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               Foreground="White"
                               FontSize="24"
                               TextAlignment="Center"><TextBlock.LayoutTransform>
        					<TransformGroup>
        						<ScaleTransform />
        						<SkewTransform />
        						<RotateTransform Angle="-90" />
        						<TranslateTransform />
        					</TransformGroup>
        				</TextBlock.LayoutTransform><Run Text="Candidat" /><Run Language="it-it"
                                                                                Text="a" /></TextBlock>
                </Border>
                <Border Grid.Column="1"
                        Margin="0"
                        Padding="5"
                        Background="White"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        RenderTransformOrigin="0.5,0.5"
                        Grid.RowSpan="2">
                    <Border.Effect>
                        <DropShadowEffect BlurRadius="16"
                                          RenderingBias="Quality"
                                          Direction="297"
                                          ShadowDepth="8"
                                          Opacity="0.38" />
                    </Border.Effect>
                    <Border.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform />
                            <SkewTransform />
                            <RotateTransform Angle="-11.419" />
                            <TranslateTransform />
                        </TransformGroup>
                    </Border.RenderTransform>
                    <ContentControl  Content="{Binding  SelectedItem, ElementName=MultimediaList}"
                                     dd:DragDropManager.DragSourceAdvisor="{StaticResource modelDragSourceAdvisor}"
                                     HorizontalAlignment="Left"
                                     VerticalAlignment="Top">
                        <ContentControl.InputBindings>
                            <MouseBinding Command="{Binding Path=OpenCurrentMultimediaCommand}"
                                          MouseAction="LeftDoubleClick" />
                        </ContentControl.InputBindings>
                    </ContentControl>
                    <!--<Image HorizontalAlignment="Left"
                           VerticalAlignment="Top"
                           dd:DragDropManager.DragSourceAdvisor="{StaticResource modelDragSourceAdvisor}"
                           Source="{Binding  SelectedItem.ImageSource, ElementName=MultimediaList}">
                        <Image.InputBindings>
                            <MouseBinding Command="{Binding Path=OpenCurrentMultimediaCommand}"
                                          MouseAction="LeftDoubleClick" />
                        </Image.InputBindings>
                    </Image>-->
                </Border>
                <ListBox  x:Name="MultimediaList"
                          IsSynchronizedWithCurrentItem="True"
                          ItemsSource="{Binding CurrentModel.Multimedia}"
                          Style="{DynamicResource DetailsCandidateListBoxStyle}"
                          Grid.Row="2"
                          Grid.Column="2" />
                <StackPanel Grid.Column="2"
                            Margin="10">
                    <TextBlock TextWrapping="Wrap"
                               Text="{Binding CurrentModel.FullName, StringFormat='Nome: {0}'}"
                               Style="{DynamicResource DetailTextBlockStyle}" />
                    <TextBlock TextWrapping="Wrap"
                               Text="{Binding CurrentModel.CanBeNaked,StringFormat='Disposta al nudo: {0}'}"
                               Style="{DynamicResource DetailTextBlockStyle}" />
                    <TextBlock TextWrapping="Wrap"
                               Text="{Binding CurrentModel.HairColor,StringFormat='Capelli: {0}'}"
                               Style="{DynamicResource DetailTextBlockStyle}" />
                    <TextBlock TextWrapping="Wrap"
                               Text="{Binding CurrentModel.EyeColor,StringFormat='Occhi: {0}'}"
                               Style="{DynamicResource DetailTextBlockStyle}" />
                </StackPanel>
            </Grid>
        </Border>

        <Button Content="Record"
                Command="{Binding RecordMovieCommand}"
                HorizontalAlignment="Right"
                Grid.Row="1"
                VerticalAlignment="Center"
                Style="{DynamicResource RecordButtonStyle}"
                Foreground="Black" />
    </Grid>
</Window>
